package com.g3.zoosite.controller;


import com.g3.zoosite.common.Result;
import com.g3.zoosite.model.DwAnimalNews;
import com.g3.zoosite.model.DwAnimalRescue;
import com.g3.zoosite.service.IDwAnimalRescueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * <p>
 * 动物救助信息表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-09-28
 */
@Api(tags = "动物救助信息接口")
@Slf4j  //日志打印
@RestController
@RequestMapping("/zoosite/dwAnimalRescue")
public class DwAnimalRescueController {

    @Autowired
    private IDwAnimalRescueService dwAnimalRescueService;


    /**
     * 查询全部动物救助信息
     * @return
     */
    @GetMapping("/loadanimalRescues")
    @ApiOperation("查询全部动物救助信息")
    public List<DwAnimalRescue> getAnimalRescues(){
        List<DwAnimalRescue> animalRescues = dwAnimalRescueService.findAnimalRescues();
        return animalRescues;
    }

    /**
     * 按id查询动物救助信息  带数据跳转页面  即页面详情
     * @return
     */
    @GetMapping("/edit/{id}")
    @ApiOperation("按id查询动物救助信息")
    public ModelAndView getAnimalRescue(@PathVariable Integer id){
        DwAnimalRescue animalRescue = dwAnimalRescueService.findAnimalRescue(id);
        //ModelAndView 使用这个来做页面跳转
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/hfy/hfy_dwjz_detail");
        mv.addObject("animalRescue",animalRescue);
        return mv;
    }

}
